<template>
    <div
        class="menus-box"
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
    >
        <div class="role-right">
            <!--查询面板-->
            <SearchPanel ref="searchPanel" :selectOptions="selectOptions" :search-config="searchConfig" @startSearch="startSearch">
            </SearchPanel>

            <!-- 查询结果 -->
            <ResultListPanel
                tableRef="table"
                ref="multipleTable"
                :checkBoxEnable="true"
                :data="dataList ? dataList : []"
                :listConfig="resultColConfig"
                :listLoading="listLoading"
                @actionClick="actionClick"
                @paginationChange="paginationChange"
                :tagTextExchange="tagTextExchange"
                @selectionChange="selectionChange"
                :actionLimit="actionLimit"
                :actionLimitName="actionLimitName"
            ></ResultListPanel>
        </div>
    </div>
</template>
<script>
import { INDEX_SEARCH_CONFIG, INDEX_SEARCH_SELECT_OPTIONS_CONFIG, INDEX_SEARCH_RESULT_ITEMS } from './config';
import ResultListPanel from '../../../components/ResultListPanel';
import SearchPanel from '../../../components/SearchPanel';
import API from '@/api';
import cloneDeep from 'lodash/cloneDeep';
import { mapGetters } from 'vuex';
import { checkStatusType } from '../../../utils/util';

export default {
    components: {
        ResultListPanel,
        SearchPanel
    },
    data() {
        return {
            dataListLoading: false,
            auditVisible: false,
            dialogVisible: false,
            dialogTitle: '新增',
            dateSelectOptions: [], // 选中的
            // 搜索项配置
            searchConfig: INDEX_SEARCH_CONFIG,
            resultColConfig: INDEX_SEARCH_RESULT_ITEMS,
            listLoading: false, // 数据列表显示状态
            dataList: [], //  数据列表
            /* 分页查询数据 */
            pageSize: 10,
            pageNum: 1,
            totalPage: 0,
            qFlag:'0',
            /* 查询条件参数 */
            dataForm: {
                name: '',
                checkStatus: '0',
            },
            type: 1,
            loading: false,
            selectOptions: INDEX_SEARCH_SELECT_OPTIONS_CONFIG
        };
    },

    mounted() {
        this.getList();
    },
    methods: {
        /***
         * 触发 行操作按钮
         * @param data
         * @param item
         */
        actionClick([data, item]) {
            if (item.alias === 'audit') {
                data.opFlag=this.qFlag;
                //送审 (2为编辑)
                this.$router.push({ path: '/iapropertyright/audit/audit', query: { itemData: data, type: 2 } });
            }
        },
        tagTextExchange([data, item]) {
            //状态
            if (item.alias == 'flowStatusEnumStr') {
                return data.flowStatusEnumStr;
            }
        },

         actionLimit([data, obj]) {

            //操作 按钮显示隐藏  

            return true;
        },
        actionLimitName([data, action]){

             if (this.qFlag== '0') { //未审核，才能操作

                if (action.alias == 'audit' && data.flowStatusEnumStr == '审核通过(完成)') {
                    return "详情";
                } else {
                    return action.name;
                }

            } else { //已审核，看详情
                  
                 return "详情";
               
            }

        },
        // 选择角色
        selectionChange(val) {
            console.log(val);
            this.dateSelectOptions = val;
        },

        /**
         * 分页器发生改变
         * @param page
         */
        paginationChange(page) {
            this.pageSize = page.pageSize;
            this.pageNum = page.pageNo;
            this.getList();
        },
        /***
         * 搜索面板出发搜索事件
         * @param params
         */
        startSearch(params) {
            this.dataForm = params;
            this.pageNum = 1;
            this.$set(this.$refs.multipleTable['pageParams'], 'pageNum', 1);

            this.getList();
        },

        getList() {
            this.qFlag=this.dataForm.checkStatus;
            let params = cloneDeep(this.dataForm);
            params.pageNum = this.pageNum;
            params.pageSize = this.pageSize;
            this.listLoading = true;
            this.loading = true;
            API.iapropertyright.getiaPropertyRightAuditList(params).then((res) => {
                this.listLoading = false;
                this.loading = false;
                // if (res.code == '0000') {
                this.totalPage = res.total;
                this.dataList = res.result.rows;
                this.$set(this.$refs.multipleTable['pageParams'], 'total', res.total);
                // }
            });
        }
    }
};
</script>
<style scoped>
.menus-box {
    background: #fff;
    padding: 20px;
    min-height: 100%;
}
</style>